﻿<view:ViewPageBase x:Class="ASPItalia.ModelVirtualCasting.Silverlight.BackOffice.Views.DomainCollectionView"
                   xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                   xmlns:data="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Data"
                   xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                   xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
                   xmlns:view="clr-namespace:ASPItalia.ModelVirtualCasting.Silverlight.BackOffice.Views"
                   xmlns:viewmodel="clr-namespace:ASPItalia.ModelVirtualCasting.Silverlight.BackOffice.ViewModels"
                   xmlns:toolkit="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Toolkit"
                   xmlns:Behaviors="clr-namespace:ASPItalia.ModelVirtualCasting.Silverlight.BackOffice.Behaviors"
                   xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
                   xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity"
                   xmlns:cmd="clr-namespace:GalaSoft.MvvmLight.Command;assembly=GalaSoft.MvvmLight.Extras.SL4"
                   xmlns:Command="clr-namespace:ASPItalia.ModelVirtualCasting.Silverlight.BackOffice.Command"
                   mc:Ignorable="d"
                   xmlns:web="clr-namespace:ASPItalia.ModelVirtualCasting.Web.RiaServices"
                   xmlns:navigation="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Navigation"
                   xmlns:ext="clr-namespace:ASPItalia.ModelVirtualCasting.Silverlight.BackOffice.MarkupExtensions"
                   xmlns:nav="clr-namespace:ASPItalia.ModelVirtualCasting.Silverlight.BackOffice.Navigation"
                   nav:Navigator.Source="{Binding}"
                   d:DesignWidth="640"
                   d:DesignHeight="480"
                   Title="CustomTypePage Page">
    <view:ViewPageBase.ViewModel>
        <viewmodel:DomainCollectionViewModel />
    </view:ViewPageBase.ViewModel>
    <Grid x:Name="LayoutRoot">
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto"></RowDefinition>
            <RowDefinition></RowDefinition>
            <RowDefinition Height="Auto"></RowDefinition>
        </Grid.RowDefinitions>

        <Border VerticalAlignment="Center"
                Background="#FF72B2E4"
                CornerRadius="0">
            <StackPanel Orientation="Horizontal">
                <StackPanel  Margin="10"
                             VerticalAlignment="Center"
                             Orientation="Horizontal">
                    <TextBlock TextWrapping="Wrap"
                               Text="{ext:Localization Key=Filter_By_Surname}"
                               VerticalAlignment="Center" />
                    <TextBox TextWrapping="Wrap"
                             Text="{Binding StringSearch, Mode=TwoWay}"
                             VerticalAlignment="Center"
                             MinWidth="224" />
                </StackPanel>
                <Button Content="Filtra"
                        HorizontalAlignment="Center"
                        VerticalAlignment="Center"
                        Margin="5,0,0,0"
                        Command="{Binding FilterCommand}"
                        MinWidth="45">
                </Button>
                <Button Content="Aggiungi"
                        HorizontalAlignment="Center"
                        VerticalAlignment="Center"
                        Margin="5,0,0,0"
                        Command="{Binding AddCommand}"
                        MinWidth="45">
                </Button>
                <Button Content="Elimina"
                        HorizontalAlignment="Center"
                        VerticalAlignment="Center"
                        Margin="5,0,0,0"
                        Command="{Binding DeleteCommand}"
                        MinWidth="45">
                </Button>
                <Button Content="Salva"
                        HorizontalAlignment="Center"
                        VerticalAlignment="Center"
                        Margin="5,0,0,0"
                        Command="{Binding SaveCommand}"
                        MinWidth="45">
                </Button>

            </StackPanel>
        </Border>

        
        <data:DataGrid AutoGenerateColumns="False"
                       Grid.Row="1"
                       HorizontalAlignment="Stretch"
                       Margin="40"
                       Name="customersGrid"
                       VerticalAlignment="Stretch"
                       ItemsSource="{Binding People}">
            <data:DataGrid.Columns>
                <data:DataGridTextColumn Binding="{Binding ID}"
                                         IsReadOnly="True"
                                         MaxWidth="40"
                                         Header="ID"
                                         Width="SizeToHeader" />
                <data:DataGridTextColumn Binding="{Binding FirstName}"
                                         Header="Nome" />
                <data:DataGridTextColumn Binding="{Binding LastName}"
                                         Header="Cognome" />
                <data:DataGridTextColumn Binding="{Binding EmailAddress}"
                                         Header="Email" />
                <data:DataGridTextColumn Binding="{Binding ResidenceCity}"
                                         Header="Città" />
                <data:DataGridTemplateColumn Header="Tipo"
                                             Width="SizeToCells">
                    <data:DataGridTemplateColumn.CellTemplate>
                        <DataTemplate>
                            <TextBlock VerticalAlignment="Center"
                                       Text="{Binding Type}" />
                        </DataTemplate>
                    </data:DataGridTemplateColumn.CellTemplate>
                    <data:DataGridTemplateColumn.CellEditingTemplate>
                        <DataTemplate>
                            <ComboBox ItemsSource="{Binding Elements, Source={StaticResource PeopleTypeCollection}}"
                                      SelectedItem="{Binding Type, Mode=TwoWay, Converter={StaticResource TypeListConverter}}"
                                      DisplayMemberPath="Name" />
                        </DataTemplate>
                    </data:DataGridTemplateColumn.CellEditingTemplate>
                </data:DataGridTemplateColumn>
            </data:DataGrid.Columns>
        </data:DataGrid>

        <data:DataPager Grid.Row="2"
                       Source="{Binding People}" />
    </Grid>
</view:ViewPageBase>
